<template>
  <div class="container">
    <Transition class="animate__animated" enter-active-class="animate__fadeInUp" leave-active-class="animate__fadeOutUp">
      <h1 class="num" :key="count">{{ count }}</h1>
    </Transition>
  </div>
</template>

<script setup>
import { ref, onMounted, onBeforeUnmount } from 'vue'
import 'animate.css'

const count = ref(new Date().getSeconds())
const timerId = null

onMounted(() => {
  timerId = setInterval(() => {
    count.value = new Date().getSeconds()
  }, 1000)
})

onBeforeUnmount(() => {
  clearInterval(timerId)
})
</script>

<style scoped>
.container {
  position: absolute;
  left: 50%;
  top: 50%;
  border: 1px solid #efefef;
  font-family: Gilroy;
  height: 100px;
  line-height: 100px;
  width: 150px;
  transform: translate(-50%, -50%);
  border-radius: 10px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.1));
  box-shadow: 1px 1px 20px rgba(0, 0, 0, 0.1);
}

.num {
  position: absolute;
  margin: 0;
  width: 100%;
  height: 100%;
  text-align: center;
  font-size: 50px;
}
</style>
